package com.adtech.adms.commons.web.listener;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

import com.adtech.adms.SessionKey;

/**
 * 
 * 用于屏蔽ip
 * @author Dormin 
 * @since 2011-6-7 
 * 
 * @Copyright (C) AD Tech Workshop All Right Reserved
 */
public class IpBlockInfo {
	private AtomicInteger count;
	private Date blockStartTime;

	public IpBlockInfo(){
		count = new AtomicInteger(0);
	}

	public Date getBlockStartTime() {
		return blockStartTime;
	}
	public void setBlockStartTime(Date blockStartTime) {
		this.blockStartTime = blockStartTime;
	}
	public void addTimes(){
		if(!needBlock()){
			count.addAndGet(1);
		}
	}
	public boolean needBlock(){
		return count.compareAndSet(SessionKey.MAX_FAIL_COUNT, SessionKey.MAX_FAIL_COUNT);
	}
}
